# ifndef __AlanTrl3_H_
# define __AlanTrl3_H_

# ifdef _MSC_VER
#	pragma pack (push, 1)
# endif

const DWORD c_dwTrl3Signature0 = 0x38CB1200;
const DWORD c_dwTrl3Signature  = 0x38CB1300;

const size_t c_cTrl3CFHdrOffset = 0x249f00;
const size_t c_cTrl3FLHdrOffset = 0x40000;

const float c_fTrl3CFAltitudeFactor = 0.02f;
const float c_fTrl3CFSpeedFactor    = 0.005f;
const float c_fTrlDOPFactor         = 0.1f;

const size_t c_cTrl3FLMaxTracks = 8;
const size_t c_cTrl3CFMaxTracks = 60;
const size_t c_cTrl3MaxPoints   = 2500;

struct CTrl3Track {
	WORD wPoints;
	WORD wNextPoint;
	char strName [12];
	char strComment [13];

	BYTE btYear;
	BYTE btMonth;
	BYTE btDay;

	DWORD dwOccupied;
	DWORD dwShow;
	DWORD dwFill;
};

template <size_t _MaxTracks>
struct CTrl3Hdr {
	DWORD dwSignature;

	WORD  wPointsInCurrentLog;
	WORD  wTracks;

	DWORD dwDate;
	DWORD dwTime;

	CTrl3Track tracks [_MaxTracks];
};

typedef CTrl3Hdr<c_cTrl3CFMaxTracks> CTrl3CFHdr;
typedef CTrl3Hdr<c_cTrl3FLMaxTracks> CTrl3FLHdr;

struct CTrl3Point {
	LONG lX, lY;
};

struct CTrl3Extra {
	WORD wSpeed;
	WORD wAltitude;
};

struct CTrl3Time {
	DWORD dop      : 8,
	      sec      : 6,
		  min      : 6,
		  hour     : 5, // NOTE: local time.
		  reserved : 7;
};

struct CTrl3CFTrackLog {
	CTrl3Point points [c_cTrl3MaxPoints];
	CTrl3Extra extra  [c_cTrl3MaxPoints];
	CTrl3Time  time   [c_cTrl3MaxPoints];
};

struct CTrl3FLTrackLog {
	CTrl3Point points [c_cTrl3MaxPoints];
	CTrl3Extra extra  [c_cTrl3MaxPoints];
};


/*
struct CTrlFile {
	CTrlTrackLog logs [c_cTrlMaxTracks];
	CTrlHdr      hdr;
};*/

# ifdef _MSC_VER
#	pragma pack (pop)
# endif

# endif // __AlanTrl3_H_